
package saxon.gui.view.swing;

import java.awt.Component;
import javax.swing.ButtonGroup;
import javax.swing.JComboBox;
import javax.swing.JLabel;
import javax.swing.JRadioButton;
import saxon.gui.view.api.XView;
import saxon.gui.view.api.XView.LanguageChoice;

/**
 *
 * @author lennyn
 */
class OptionsPanel extends VPanel {
	private final JComboBox defaultNSField = new JComboBox(Const.namespaces);
	private final JRadioButton xpath2RadioButton = new JRadioButton("XPath 2.0");
	private final JRadioButton xqueryRadioButton = new JRadioButton("XQuery 1.0", true);

	OptionsPanel() {
		defaultNSField.setEditable(true);

		ButtonGroup group = new ButtonGroup();
		group.add(xpath2RadioButton);
		group.add(xqueryRadioButton);

		this.add(new HPanel(new JLabel("Default namespace:"), defaultNSField, HPanel.glue()));
		this.add(VPanel.space(5));
		this.add(new HPanel(new JLabel("Language:"), xpath2RadioButton, xqueryRadioButton, HPanel.glue()));
	}

	String getDefaultNS() {
		return defaultNSField.getSelectedItem().toString();
	}

	LanguageChoice getLanguageChoice() {
		if (xpath2RadioButton.isSelected())
			return XView.LanguageChoice.XPATH2;
		else
			return XView.LanguageChoice.XQUERY;
	}

	@Override
	public void setEnabled(boolean enabled) {
		for (Component comp: this.getComponents())
			comp.setEnabled(enabled);
	}
}
